/**
 * 用户列表 add by gsh
 */
$(function() {
	$("#btnAdd").click(function() {
		var index = msgWnd.open({
			title : "添加商品信息",
			skin : 'layui-layer-lan',
			type : 2,
			shade : 0.5,
			area : [ "870px", "620px" ],
			maxmin : true,
			content : '/goods/add',
			zIndex : layer.zIndex
		});
	});
	
	$("#chkAll").change(function() {
		var chkStatus = $(this).is(":checked");
		$("[id^=chk]:not(#chkAll)").each(function() {
			this.checked = chkStatus;
		});
	});
});

function getChecked() {
	var map = $("[id^=chk]:not(#chkAll)").map(function() {
		if (this.checked)
			return this.value;
	});
	return map.get();
}

function edit(id) {
	var index = msgWnd.open({
		title : "修改商品信息",
		skin : 'layui-layer-lan',
		type : 2,
		shade : 0.5,
		area : [ "800px", "520px" ],
		maxmin : true,
		content : '/goods/edit/' + id,
		zIndex : layer.zIndex
	});
}

function enableGoods(id, isEnable) {
	$.ajax({
		type : "POST",
		url : "/goods/enable/",
		data : "id=" + id + "&isEnable=" + isEnable,
		dataType : "json",
		success : function(msg) {
			if (msg.data.status == 1) {
				msgTools.alert("修改商品状态", "修改成功。", 1000);
				if(typeof(reloadPg)!="undefined")
					reloadPg();
				else
					window.location.href = window.location.href;
			} else {
				msgTools.alert("修改商品状态", "修改失败。", 2000);
			}
		}
	});
}
